package com.example.adminui.controller;

import com.example.adminui.entity.FollowRecord;
import com.example.adminui.service.FollowRecordService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/follow-records")
public class FollowRecordController {
    private final FollowRecordService followRecordService;

    public FollowRecordController(FollowRecordService followRecordService) {
        this.followRecordService = followRecordService;
    }

    @PostMapping
    public void create(@RequestBody FollowRecord followRecord) {
        followRecordService.save(followRecord);
    }

    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestBody FollowRecord followRecord) {
        followRecord.setId(id);
        followRecordService.updateById(followRecord);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        followRecordService.removeById(id);
    }

    @GetMapping("/{id}")
    public FollowRecord get(@PathVariable Long id) {
        return followRecordService.getById(id);
    }
}